// 引入request
import request from '../util/request.js';
import config from '../util/config.js';
const DictItemRequest = {
    BASE_URL : config.sysUrl + "/sys/dictItem",
    // 请求过程在这里开发，不在.vue文件中开发
    /**
     * 多条件分页查询dictItem列表
     * @param dictItem
     * @param callBack
     */
    loadDictItem(dictItem, callBack){
        // 拼接url  /sys/queryByPage?xxx
        let url = this.BASE_URL + "/queryByPage";
        // 调用request进行请求  http://lcation
        request.get(url,dictItem,callBack);
    },
    /**
     * 新增字典的API
     * @param dictItem
     * @param callBack
     */
    addDictItem(dictItem,callBack){
        let url = this.BASE_URL + "/save"
        request.post(url,dictItem,callBack);
    },
    /**
     * 通过id加载字典信息的API
     * @param dictItemId
     * @param callBack
     */
    getById(dictItemId,callBack){
        let url = this.BASE_URL + "/queryById?dictItemId=" + dictItemId;
        request.get(url,null,callBack);
    }
    ,
    /**
     * 修改字典信息的API
     * @param dictItem
     * @param callBack
     */
    updateDictItem(dictItem,callBack){
        let url = this.BASE_URL + "/update";
        request.post(url,dictItem,callBack);
    },
    /**
     *  删除字典的API
     * @param dictItemId
     * @param callBack
     */
    deleteDictItem(dictItemId,callBack){
        request.get(this.BASE_URL + "/delete?dictItemId=" + dictItemId,null,callBack);
    },
    /**
     * 批量删除字典的API
     * @param dictItemIds
     * @param callBack
     */
    deletes(dictItemIds,callBack){
        let url = this.BASE_URL + "/deletes?a=1";
        for (let i = 0; i < dictIds.length; i++){
            url += "&dictItemId="+dictIds[i];
        }
        request.get(url,null,callBack);
    }
}
// 导出我们申明的dictrequest对象
export default DictItemRequest;